package com.yunhe.device.domain.device;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;

import java.util.List;

/**
 * 设备树形对象
 * @author liuronglei
 */
@NodeEntity
public class DeviceTree implements Comparable<DeviceTree> {

    private Long id;
    private Long code;
    private String type;
    private String title;
    private Object object;
    private Object child;
    private Integer level;
    @Relationship(type = "HAS_CHILD")
    private List<DeviceTree> children;

    @Override
    public int compareTo(DeviceTree o) {
        if (o == null) {
            return 1;
        }
        return this.getLevel().compareTo(o.getLevel());
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getCode() {
        return code;
    }

    public void setCode(Long code) {
        this.code = code;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @JsonIgnore
    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }

    public List<DeviceTree> getChildren() {
        return children;
    }

    public void setChildren(List<DeviceTree> children) {
        this.children = children;
    }

    @JsonIgnore
    public Object getChild() {
        return child;
    }

    public void setChild(Object child) {
        this.child = child;
    }

    @JsonIgnore
    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }
}
